package com.iqismart.shorturl.service.impl;

import com.iqismart.shorturl.config.WebSite;
import com.iqismart.shorturl.model.EntityConfig;
import com.iqismart.shorturl.repository.ConfigRepository;
import com.iqismart.shorturl.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description
 * @Auther sty
 * @createTime 2020-03-05 17:42
 */
@Service
@Slf4j
public class ConfigServiceImpl implements ConfigService {
    @Autowired
    private ConfigRepository configRepository;

    @Autowired
    private WebSite webSite;

    @Override
    public Map<String, String> get() {
        Map<String,String> map = new HashMap<>();
        map.put("domain",webSite.url);
        map.put("email","364337403@qq.com");
        map.put("icp","豫ICP备18000045号 ");
        for (EntityConfig entityConfig : configRepository.findAll()) {
            map.put(entityConfig.getName(),entityConfig.getValue());
        }

        return map;
    }
}
